// 模拟用户数据
export const users = [
  {
    id: '1',
    username: 'admin',
    password: '123456',
    name: '管理员',
    avatar: 'https://tdesign.gtimg.com/site/avatar.jpg',
    role: 'admin',
    permissions: ['*']
  },
  {
    id: '2',
    username: 'operator',
    password: '123456',
    name: '运营人员',
    avatar: 'https://tdesign.gtimg.com/site/avatar.jpg',
    role: 'operator',
    permissions: ['content:*', 'activity:*']
  }
]

// 模拟登录接口
export function mockLogin(username: string, password: string) {
  // 查找用户
  const user = users.find(user => user.username === username && user.password === password)
  
  if (user) {
    return {
      code: 0,
      data: {
        token: `mock_token_${user.id}_${Date.now()}`,
        user: {
          id: user.id,
          name: user.name,
          avatar: user.avatar,
          role: user.role
        }
      },
      message: '登录成功'
    }
  } else {
    return {
      code: 1001,
      data: null,
      message: '用户名或密码错误'
    }
  }
}

// 模拟获取用户信息接口
export function mockGetUserInfo() {
  // 模拟已登录用户
  const mockUser = users[0] // 默认返回管理员信息
  
  return {
    code: 0,
    data: {
      id: mockUser.id,
      name: mockUser.name,
      avatar: mockUser.avatar,
      role: mockUser.role,
      permissions: mockUser.permissions
    },
    message: '获取用户信息成功'
  }
}

// 模拟登出接口
export function mockLogout() {
  return {
    code: 0,
    data: null,
    message: '登出成功'
  }
} 